package 牛客周赛.牛客周赛Round85;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Title: B
 * @Author 贾金博
 * @Package 牛客周赛.牛客周赛Round85
 * @Date 2025/4/8 上午9:44
 * @description: This is B
 */
public class B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 10];

        for(int i = 1; i <= n; i ++ ) {
            a[i] = sc.nextInt();
        }

        // 排序
        Arrays.sort(a, 1, n + 1); // 注意下标问题

        int sum = 0;

        for(int i = 1; i <= n; i ++ ) {
            if(i % 2 == 1) {
                sum += a[i];
            } else {
                sum -= a[i];
            }
        }
        System.out.println(sum);

    }
}
